<template>
  <LayoutContainer>
    <div>
      <h2>{{ $t('educationTiming') }}</h2>
      <UiFormEdition
        :model="EducationTiming"
        go-back-route="/parameters/education_timings"
      >
        <template #default="{ entity }">
          <UiInputNumber
            v-model="entity.timing"
            field="educationTiming"
            :rules="rules()"
          />
        </template>
      </UiFormEdition>
    </div>
  </LayoutContainer>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import EducationTiming from '~/models/Education/EducationTiming'

const i18n = useI18n()

const rules = () => [
  (timing: string | null) =>
    (timing !== null && parseInt(timing) > 0) || i18n.t('please_enter_a_value'),
]
</script>
